﻿using System;

namespace SharpSqlAnalyzer.nodes
{
	// Token: 0x0200030D RID: 781
	public class TMergeInsertClause : TParseTreeNode
	{
		// Token: 0x1700064F RID: 1615
		// (get) Token: 0x06001BA5 RID: 7077 RVA: 0x0032F6EF File Offset: 0x0032D8EF
		// (set) Token: 0x06001BA6 RID: 7078 RVA: 0x0032F6F7 File Offset: 0x0032D8F7
		public virtual TObjectName RowTypeValue
		{
			get
			{
				return this.rowTypeValue;
			}
			set
			{
				this.rowTypeValue = value;
			}
		}

		// Token: 0x17000650 RID: 1616
		// (get) Token: 0x06001BA7 RID: 7079 RVA: 0x0032F700 File Offset: 0x0032D900
		// (set) Token: 0x06001BA8 RID: 7080 RVA: 0x0032F708 File Offset: 0x0032D908
		public virtual TObjectNameList ColumnList
		{
			get
			{
				return this.columnList;
			}
			set
			{
				this.columnList = value;
			}
		}

		// Token: 0x17000651 RID: 1617
		// (get) Token: 0x06001BA9 RID: 7081 RVA: 0x0032F711 File Offset: 0x0032D911
		// (set) Token: 0x06001BAA RID: 7082 RVA: 0x0032F719 File Offset: 0x0032D919
		public virtual TExpression InsertWhereClause
		{
			get
			{
				return this.insertWhereClause;
			}
			set
			{
				this.insertWhereClause = value;
			}
		}

		// Token: 0x17000652 RID: 1618
		// (get) Token: 0x06001BAB RID: 7083 RVA: 0x0032F722 File Offset: 0x0032D922
		// (set) Token: 0x06001BAC RID: 7084 RVA: 0x0032F72A File Offset: 0x0032D92A
		public virtual TResultColumnList Valuelist
		{
			get
			{
				return this.valuelist;
			}
			set
			{
				this.valuelist = value;
			}
		}

		// Token: 0x06001BAD RID: 7085 RVA: 0x0032F734 File Offset: 0x0032D934
		public override void init(object arg1, object arg2, object arg3)
		{
			this.columnList = (TObjectNameList)arg1;
			if (arg2 is TResultColumnList)
			{
				this.valuelist = (TResultColumnList)arg2;
			}
			else if (arg2 is TObjectName)
			{
				this.rowTypeValue = (TObjectName)arg2;
			}
			else if (arg2 is TObjectNameList)
			{
				this.valuelist = new TResultColumnList();
				TObjectNameList tobjectNameList = (TObjectNameList)arg2;
				for (int i = 0; i < tobjectNameList.size(); i++)
				{
					TResultColumn tresultColumn = new TResultColumn();
					TExpression texpression = new TExpression();
					texpression.init(EExpressionType.simple_object_name_t);
					TObjectName objectName = tobjectNameList.getObjectName(i);
					objectName.ObjectType = 1;
					texpression.ObjectOperand = objectName;
					texpression.startToken = objectName.startToken;
					texpression.endToken = objectName.endToken;
					tresultColumn.init(texpression);
					this.valuelist.addResultColumn(tresultColumn);
				}
			}
			if (arg3 != null)
			{
				this.insertWhereClause = (TExpression)arg3;
			}
		}

		// Token: 0x06001BAE RID: 7086 RVA: 0x0032F81C File Offset: 0x0032DA1C
		public override void doParse(TCustomSqlStatement psql, ESqlClause plocation)
		{
			if (this.columnList != null)
			{
				for (int i = 0; i < this.columnList.size(); i++)
				{
					TObjectName objectName = this.columnList.getObjectName(i);
					objectName.Location = ESqlClause.insertColumn;
					psql.TargetTable.ObjectNameReferences.addObjectName(objectName);
					psql.TargetTable.LinkedColumns.addObjectName(objectName);
					objectName.SourceTable = psql.TargetTable;
				}
			}
			if (this.valuelist != null)
			{
				this.valuelist.doParse(psql, ESqlClause.insertValues);
			}
			if (this.insertWhereClause != null)
			{
				this.insertWhereClause.doParse(psql, ESqlClause.where);
			}
		}

		// Token: 0x06001BAF RID: 7087 RVA: 0x0032F8B5 File Offset: 0x0032DAB5
		public override void accept(TParseTreeVisitor v)
		{
			v.preVisit(this);
			v.postVisit(this);
		}

		// Token: 0x06001BB0 RID: 7088 RVA: 0x0032F8C8 File Offset: 0x0032DAC8
		public override void acceptChildren(TParseTreeVisitor v)
		{
			v.preVisit(this);
			if (this.columnList != null)
			{
				this.columnList.acceptChildren(v);
			}
			if (this.valuelist != null)
			{
				this.valuelist.acceptChildren(v);
			}
			if (this.insertWhereClause != null)
			{
				this.insertWhereClause.acceptChildren(v);
			}
			v.postVisit(this);
		}

		// Token: 0x040019FF RID: 6655
		private TExpression insertWhereClause;

		// Token: 0x04001A00 RID: 6656
		private TObjectNameList columnList;

		// Token: 0x04001A01 RID: 6657
		private TResultColumnList valuelist;

		// Token: 0x04001A02 RID: 6658
		private TObjectName rowTypeValue;
	}
}
